package com.oracle.kadu;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Properties;
import java.util.Date;

public class log5j {
	private static Properties p;
	private static String levels = "info-warn-exception-error";
	
	static{
		p = new Properties();
		
		try {
			p.load(new FileInputStream("log.properties"));
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	public static void println(String message){
		if(p.getProperty("println").equals("on")){
		System.out.println(message);
		}
	}
			
	public static void client(String message){
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat(p.getProperty("pattern"));
		
		PrintWriter out = null;
		
		try {
			out = new PrintWriter(new FileOutputStream(sdf.format(date)+".log",true));
			out.println(message);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally{
			if(out!=null){
				out.close();
			}
		}
		
		
		
	}

}
